home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / load_scenario.gl.p < prev    next >
Text File  |  2003-01-28  |  9KB  |  294 lines

  1. {
  2.   ActiveWhileHidden = TRUE; 
  3.   Hidden = TRUE;
  4.      
  5.   ChildID = {
  6.    
  7.     GuiAnimation("plate") {
  8.       AnimationID = "anim/guage_gui/guage_window.pcx";
  9.       X = 0;
  10.       Y = 0;
  11.       Width = 500;
  12.       Height = 430;
  13.     },     
  14.  
  15.     GuiAnimation("guages") {
  16.       AnimationID = "anim/guage_gui/window/guagy.anm";
  17.       X = 0;
  18.       Y = 0;
  19.       Width = 340;
  20.       Height = 360;
  21.     },
  22.  
  23.     GuiAnimation("num_player_label") {
  24.       X = 120;
  25.       Y = 70;
  26.       HorizontalAlign=LEFT;
  27.       Width = 10;
  28.       Height = 10;
  29.       FontID = "font/square_black_on_gray_9.tf";
  30.       TextID = Mangle(127/*"Number of Players:"*/);
  31.     },
  32.  
  33.     GuiButtonGroup("1Player") {
  34.       X = 180;
  35.       Y = 110;
  36.       RadioGroupID = 1;
  37.       ScriptID = Script {
  38.         @show {
  39.           ResParseEvent(SELF,"@activate");
  40.           ResPropSetResID(SELF, "ActiveButtonID", GuiChildByName(SELF, "radio_button_selected"));
  41.           ResPropSetResID(GuiSiblingByName("2Player"), "ActiveButtonID", GuiSiblingByName("2Player/radio_button_unselected"));
  42.         } 
  43.         @activate {
  44.           ResPropSetInt(ResByName("Game"), "game_num_players", 1 );
  45.           ResPropSetInt(GuiSiblingByName("player2_name"),"Hidden",TRUE);
  46.         }
  47.       };
  48.       ChildID = {
  49.  
  50.         GuiButton("radio_button_unselected") {
  51.           StyleID = "gui/bs/radiounsel.gbs";
  52.           VerticalAlign = ABOVE;
  53.           TextDownOffsetX = 0;
  54.           TextDownOffsetY = 0;
  55.           VerticalPadding = 4;
  56.           TextID = Mangle(128/*"1"*/);
  57.           FontID = "font/square_black_on_gray_9.tf";
  58.         },
  59.  
  60.         GuiButton("radio_button_selected") {
  61.           StyleID = "gui/bs/radiosel.gbs";
  62.           VerticalAlign = ABOVE;
  63.           TextDownOffsetX = 0;
  64.           TextDownOffsetY = 0;
  65.           VerticalPadding = 4;
  66.           TextID = Mangle(129/*"1"*/);
  67.           FontID = "font/square_black_on_gray_9.tf";
  68.         }
  69.       };
  70.     },
  71.  
  72.     GuiButtonGroup("2Player") {
  73.       X = 210;
  74.       Y = 110;
  75.       RadioGroupID = 1;
  76.       ScriptID = Script {
  77.         @activate {
  78.           ResPropSetInt(ResByName("Game"), "game_num_players", 2 );
  79.           ResPropSetInt(GuiSiblingByName("player2_name"),"Hidden",FALSE);
  80.         }
  81.       };
  82.       ChildID = {
  83.           GuiButton("radio_button_unselected") {
  84.           StyleID = "gui/bs/radiounsel.gbs";
  85.           VerticalAlign = ABOVE;
  86.           TextDownOffsetX = 0;
  87.           TextDownOffsetY = 0;
  88.           VerticalPadding = 4;
  89.           TextID = Mangle(130/*"2"*/);
  90.           FontID = "font/square_black_on_gray_9.tf";
  91.         },
  92.  
  93.         GuiButton("radio_button_selected") {
  94.           StyleID = "gui/bs/radiosel.gbs";
  95.           VerticalAlign = ABOVE;
  96.           TextDownOffsetX = 0;
  97.           TextDownOffsetY = 0;
  98.           VerticalPadding = 4;
  99.           TextID = Mangle(131/*"2"*/);
  100.           FontID = "font/square_black_on_gray_9.tf";
  101.         }
  102.       };
  103.     },
  104.  
  105.     GuiTextInput("player1_name") {
  106.       AnimationID = "gui/square/window/window_text_entry.pcx";
  107.       X = 180;
  108.       Y = 140;
  109.       Width = 120;
  110.       Height = 22;
  111.       InsertCursorID = "gui/dash/tab/insert_cursor.pcx";
  112.       OverwriteCursorID = "gui/dash/tab/overwrite_cursor.pcx";
  113.       TextX = -50;
  114.       FontID = "font/square_black_on_gray_9.tf";
  115.       InputFontID = "font/verdana_9_black.tf";
  116.       TextID = Mangle(132/*"Name:"*/);
  117.       InputText = 32:"player 1";
  118.       ScriptID = Script {
  119.         @mousedown {
  120.           if (StrExact(ResPropGetStr(SELF,"InputText"),"player 1")) {
  121.             ResPropSetStr(SELF,"InputText","");
  122.           }
  123.         }
  124.       }; 
  125.     },
  126.  
  127.  
  128.  
  129.     GuiTextInput("player2_name") {
  130.       AnimationID = "gui/square/window/window_text_entry.pcx";
  131.       X = 180;
  132.       Y = 180;
  133.       InsertCursorID = "gui/dash/tab/insert_cursor.pcx";
  134.       OverwriteCursorID = "gui/dash/tab/overwrite_cursor.pcx";
  135.       Width = 120;
  136.       Height = 22;
  137.       TextX = -50;
  138.       FontID = "font/square_black_on_gray_9.tf";
  139.       TextID = Mangle(133/*"Name:"*/);
  140.       InputText = 32:"player 2";
  141.       InputFontID = "font/verdana_9_black.tf";
  142.       ScriptID = Script {
  143.         @mousedown {
  144.           if (StrExact(ResPropGetStr(SELF,"InputText"),"player 2")) {
  145.             ResPropSetStr(SELF,"InputText","");
  146.           }
  147.         }
  148.       };
  149.     },
  150.  
  151.     GuiAnimation("scenario_label") {
  152.       X = 120;
  153.       Y = 220;
  154.       HorizontalAlign=LEFT;
  155.       Width = 10;
  156.       Height = 10;
  157.       FontID = "font/square_black_on_gray_9.tf";
  158.       TextID = Mangle(134/*"Scenario:"*/);
  159.     },
  160.  
  161.     GuiListbox("scenario_listbox") {
  162.       X = 130;
  163.       Y = 235;
  164.       Height = 100;
  165.       Width = 250;
  166.       ListHilightedColor = #7FAFFF;
  167.       ScriptID = Script {
  168.         @show {
  169.           GuiListboxClear(SELF);
  170.           GuiListboxLoadDirFiltered(SELF, CVarGetStr("SavedScenarioDir"), "scn");
  171.           GuiListboxSetSelected(SELF, StrListAt(ResPropGetResID(SELF, "StrListID"), 0));
  172.         }
  173.       };
  174.  
  175.       StrListID = StrList {
  176.         Indexed = TRUE;
  177.         Size = 10240;
  178.       };
  179.  
  180.       ChildID = {
  181.         GuiScrollBar ("sb") {
  182.           Kind = VERTICAL;
  183.           ChildID = {
  184.             GuiButton("thumb") {
  185.               StyleID = "gui/square/scrollbar/sb_thumb.gbs";
  186.             },
  187.             GuiButton("dec") {
  188.               StyleID = "gui/square/scrollbar/sb_uarrow.gbs";
  189.             },
  190.             GuiButton("inc") {
  191.               StyleID = "gui/square/scrollbar/sb_darrow.gbs";
  192.             }
  193.           };
  194.         }
  195.       };
  196.     },
  197.  
  198.     GuiButton("main_menu") {
  199.       X = 100;
  200.       Y = 340;
  201.       TextID = Mangle(135/*"Main Menu"*/);
  202.       StyleID = "gui/bs/square.gbs";
  203.       FontID = "font/square_black_on_gray_9.tf";
  204.       Width = 160;
  205.       AutoSize = HEIGHT;
  206.       ScriptID = Script {
  207.         @activate {
  208.           resid mc;
  209.           mc = ResByName("splash_screen.gl/menu_controller");
  210.           ResPropSetResID(mc,"panel_to_display", ResByName("main_menu.gl"));
  211.         }
  212.       };
  213.     },
  214.     
  215.     GuiButton("load_scenario") {
  216.       X = 260;
  217.       Y = 340;
  218.       TextID = Mangle(136/*"Load Scenario"*/);
  219.       StyleID = "gui/bs/square.gbs";
  220.       FontID = "font/square_black_on_gray_9.tf";
  221.       Width = 160;
  222.       AutoSize = HEIGHT;
  223.       ScriptID = Script {
  224.         @activate {
  225.           str scenario_to_load;
  226.           str tmp;
  227.           resid com_id;
  228.           int i;
  229.           int j;
  230.           resid player_id;
  231.           resid player_scenario_id;
  232.  
  233.           scenario_to_load = GuiListboxGetSelected(GuiSiblingByName("scenario_listbox"));
  234.           if (StrExact(scenario_to_load, "")) {
  235.             /* TODO: report error */
  236.             stop;
  237.           } else {
  238.             /* set the current player to player 1 */
  239.             ResPropSetResID(ResByName("Game"), "game_cur_player", ResByName("Player1"));
  240.  
  241.             /* set the players names into the player objects */
  242.             ResPropSetStr(ResByName("Player1"), "player_name", ResPropGetStr(GuiSiblingByName("player1_name"), "InputText") );
  243.             ResPropSetStr(ResByName("Player2"), "player_name", ResPropGetStr(GuiSiblingByName("player2_name"), "InputText") );
  244.  
  245.             /* load scenario */
  246.             ResLoadAs("ScenarioGroup", "ScenarioGroup", StrFormatStr("%s%s",CVarGetStr("SavedScenarioDir"), scenario_to_load));
  247.  
  248.             i = 0;
  249.             while (i<2) {
  250.               if (i==0) {
  251.                 player_id = ResByName("Player1");
  252.                 i=1;
  253.               } else {
  254.                 player_id = ResByname("Player2");
  255.                 i=2;
  256.               }
  257.  
  258.               player_scenario_id = ResPropGetResID(player_id, "scenario_id");
  259.               ResPropSetInt(player_id, "commodity_number_of", ResPropGetInt(player_scenario_id, "scenario_commodity_number_of"));
  260.  
  261.               com_id = ResPropGetResID(player_id, "commodity_bonus");
  262.               ResPropSetStr(com_id, "commodity_name", ResPropGetStr(player_scenario_id, "scenario_commodity_bonus"));
  263.               ResPropSetInt(com_id, "commodity_state", 0);
  264.  
  265.               j=1;
  266.               while(j<=12) {
  267.                 tmp = StrFormatStr("commodity_%d", j);
  268.                 com_id = ResPropGetResID(player_id, tmp);
  269.                 tmp = StrFormatStr("scenario_commodity_name_%d", j);
  270.                 ResPropSetStr(com_id, "commodity_name", ResPropGetStr(player_scenario_id, tmp));
  271.                 ResPropSetInt(com_id, "commodity_state", 0);
  272.                 j+=1;
  273.               }
  274.             }
  275.  
  276.  
  277.             /* init a game */
  278.             ResParseEvent(ResByName("common/init_game.c4"),"@INIT_GAME");
  279.  
  280.             release("floor");
  281.             mark("floor");
  282.  
  283.             /* load the loading screen */
  284.             ResByName("loader.gl");
  285.  
  286.             /* load the dispatch screen */
  287.             /* ResByName("laptop.gl");  done by loader now */            
  288.           }
  289.         }
  290.       };
  291.     }
  292.   };
  293. }
  294.